﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrokerBase.Lib.Policy;

namespace broker.duty.YG
{
    /// <summary>
    /// 阳光_财富年年两全保险_主_分红型
    /// </summary>
    class Class2
    {
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Period > 0)
            {
                da.Value = ppa.Amount * 0.2;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.Age == 60 || ppa.Age == 65 || ppa.Age == 70 || ppa.Age == 75 || ppa.Age == 80)
            {
                da.Value = ppa.TotalFee * 0.2;
            }
        }

        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("意外身故"))
            {
                if (ppa.Age < 18)
                {
                    da.Value = ppa.TotalFee;

                }
                else if (ppa.Age >= 18 && ppa.Age <= 60)
                {
                    double s = ppa.PolicyActing.Policy.Fee * ppa.PolicyActing.Policy.PaymentPeriodLength * 10;

                    double v = ppa.TotalFee * 1000000;

                    if (s > v)
                    {
                        da.Value = v;
                        da.Description = "不能大于累计已交保险费与100万元之和";
                    }
                    else
                    {
                        da.Value = s;

                    }
                }
                else if (ppa.Age > 60)
                {
                    double s=ppa.TotalFee-ppa.GetDutyTotalValue("生存保险");

                    da.Value = s > 0 ? s : 0;
                }

                ppa.IsCurrentFinish = true;
            }
        }
        /// <summary>
        /// 疾病身故给付
        /// </summary>
        /// <param name="ppa"></param>
        /// <param name="da"></param>
        public void Calc1(IPolicyPeriodActing ppa, IDutyActing da)
        {
            if (ppa.SchemePeriodActing.InsurantStates.Contains("疾病身故"))
            {
                double s = ppa.TotalFee - ppa.GetDutyTotalValue("生存保险");

                da.Value = s > 0 ? s : 0;
            }
        }

    }
}
